<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  

  
  <title>test_edge_example1.m | blogData_matlab</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta name="description" content="测试：G:_fromYanHan\edge_example1.m">
<meta property="og:type" content="article">
<meta property="og:title" content="test_edge_example1.m">
<meta property="og:url" content="http://lxydd.gitee.io/blog_matlab/2019/10/11/est-edge-example1-m/index.html">
<meta property="og:site_name" content="blogData_matlab">
<meta property="og:description" content="测试：G:_fromYanHan\edge_example1.m">
<meta property="og:locale" content="en_US">
<meta property="og:image" content="http://lxydd.gitee.io/blog_matlab/blog_matlab/2019/10/11/est-edge-example1-m/edge_example1.m.png">
<meta property="article:published_time" content="2019-10-11T06:49:00.000Z">
<meta property="article:modified_time" content="2020-04-08T12:48:07.146Z">
<meta property="article:author" content="John Doe">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="http://lxydd.gitee.io/blog_matlab/blog_matlab/2019/10/11/est-edge-example1-m/edge_example1.m.png">
  
    <link rel="alternate" href="/blog_matlab/atom.xml" title="blogData_matlab" type="application/atom+xml">
  
  
    <link rel="icon" href="/favicon.png">
  
  
    <link href="//fonts.googleapis.com/css?family=Source+Code+Pro" rel="stylesheet" type="text/css">
  
  
<link rel="stylesheet" href="/blog_matlab/css/style.css">

<meta name="generator" content="Hexo 4.2.0"></head>

<body>
  <div id="container">
    <div id="wrap">
      <header id="header">
  <div id="banner"></div>
  <div id="header-outer" class="outer">
    <div id="header-title" class="inner">
      <h1 id="logo-wrap">
        <a href="/blog_matlab/" id="logo">blogData_matlab</a>
      </h1>
      
    </div>
    <div id="header-inner" class="inner">
      <nav id="main-nav">
        <a id="main-nav-toggle" class="nav-icon"></a>
        
          <a class="main-nav-link" href="/blog_matlab/">Home</a>
        
          <a class="main-nav-link" href="/blog_matlab/archives">Archives</a>
        
      </nav>
      <nav id="sub-nav">
        
          <a id="nav-rss-link" class="nav-icon" href="/blog_matlab/atom.xml" title="RSS Feed"></a>
        
        <a id="nav-search-btn" class="nav-icon" title="Search"></a>
      </nav>
      <div id="search-form-wrap">
        <form action="//google.com/search" method="get" accept-charset="UTF-8" class="search-form"><input type="search" name="q" class="search-form-input" placeholder="Search"><button type="submit" class="search-form-submit">&#xF002;</button><input type="hidden" name="sitesearch" value="http://lxydd.gitee.io/blog_matlab"></form>
      </div>
    </div>
  </div>
</header>
      <div class="outer">
        <section id="main"><article id="post-est-edge-example1-m" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/blog_matlab/2019/10/11/est-edge-example1-m/" class="article-date">
  <time datetime="2019-10-11T06:49:00.000Z" itemprop="datePublished">2019-10-11</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/blog_matlab/categories/%E6%B5%8B%E8%AF%95%E4%BB%A3%E7%A0%81/">测试代码</a>
  </div>

  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 class="article-title" itemprop="name">
      test_edge_example1.m
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <p>测试：G:_fromYanHan\edge_example1.m</p>
<a id="more"></a>
<figure class="highlight matlab"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">%调用matlab库函数（edge）实现边缘提取的实例以及注意事项</span></span><br><span class="line">img = imread(<span class="string">'Test_FenGe_zz.jpg'</span>); <span class="comment">%读取图像</span></span><br><span class="line">[m,n,dim] = <span class="built_in">size</span>(img); <span class="comment">%识别图像的尺寸，其中m为行数，n为列数，dim为每个像素点包含的数据个数，灰度图为1，彩色图&gt;1.</span></span><br><span class="line"><span class="keyword">if</span> dim &gt; <span class="number">1</span> <span class="comment">%dim&gt;1则为彩色图，需要转换</span></span><br><span class="line">    [imgout,thresh] = edge(rgb2gray(img),<span class="string">'canny'</span>); </span><br><span class="line"><span class="keyword">else</span></span><br><span class="line">    [imgout,thresh] = edge(img,<span class="string">'canny'</span>); </span><br><span class="line"><span class="keyword">end</span></span><br><span class="line"></span><br><span class="line"><span class="comment">%t1=now;%disp(datestr(now,'HH:MM:SS.FFF'))</span></span><br><span class="line">tic</span><br><span class="line"><span class="keyword">if</span> dim&gt;<span class="number">1</span></span><br><span class="line">    [T2,dp,dq] = edge_linyu_youhua( rgb2gray(img),imgout,<span class="number">7</span>,<span class="number">40</span> );</span><br><span class="line"><span class="keyword">else</span></span><br><span class="line">    [T2,dp,dq] = edge_linyu0( img,imgout,<span class="number">7</span>,<span class="number">40</span> );</span><br><span class="line"><span class="keyword">end</span></span><br><span class="line">toc</span><br><span class="line"><span class="comment">% t2=now;</span></span><br><span class="line"><span class="comment">% tt=t2-t1;</span></span><br><span class="line"><span class="comment">% disp(datestr(tt,'HH:MM:SS.FFF'))</span></span><br><span class="line"><span class="comment">% time=toc-tic;</span></span><br><span class="line"><span class="comment">% disp(datestr(now,'HH:MM:SS.FFF'))</span></span><br><span class="line"></span><br><span class="line"><span class="comment">%edge 函数使用方法：</span></span><br><span class="line"><span class="comment">%输出参数中，若只设一个参数则默认为提取边缘后的图像，其中边缘点为1，其余为0，尺寸同原图。</span></span><br><span class="line"><span class="comment">%若设两个输出参数，则第二个参数为算法采用的阈值，阈值数据类型会在下面输入参数中说明</span></span><br><span class="line"></span><br><span class="line"><span class="comment">%输入参数：</span></span><br><span class="line"><span class="comment">%[a,method,thresh,sigma,thinning,H,kx,ky] = parse_inputs(varargin&#123;:&#125;);</span></span><br><span class="line"><span class="comment">%上方为edge函数内输入参数的顺序</span></span><br><span class="line"><span class="comment">%第一个参数为原图</span></span><br><span class="line"><span class="comment">%第二个参数为选取的边缘算法的名称</span></span><br><span class="line"><span class="comment">%</span></span><br><span class="line"><span class="comment">%   Sobel Method</span></span><br><span class="line"><span class="comment">%   ------------</span></span><br><span class="line"><span class="comment">%   BW = EDGE(I,'sobel') 选用Sobel method.（自动选取阈值）</span></span><br><span class="line"><span class="comment">%</span></span><br><span class="line"><span class="comment">%   BW = EDGE(I,'sobel',THRESH) 以输入参数THRESH为阈值进行计算</span></span><br><span class="line"><span class="comment">%  </span></span><br><span class="line"><span class="comment">%   [BW,thresh] = EDGE(I,'sobel',...) 同时返回阈值.</span></span><br><span class="line"><span class="comment">% prewitt 与 roberts 算法输入输出参数与sobel 完全一致</span></span><br><span class="line"><span class="comment">% [BW,thresh] = EDGE(I,'prewitt',...)</span></span><br><span class="line"><span class="comment">%  [BW,thresh] = EDGE(I,'sobel',...)</span></span><br><span class="line"></span><br><span class="line"><span class="comment">%   Laplacian of Gaussian Method （LOG算子）</span></span><br><span class="line"><span class="comment">%   ----------------------------</span></span><br><span class="line"><span class="comment">%   BW = EDGE(I,'log') .选用LOG算子.（自动选取阈值）</span></span><br><span class="line"><span class="comment">%</span></span><br><span class="line"><span class="comment">%   BW = EDGE(I,'log',THRESH) 以输入参数THRESH为阈值进行计算</span></span><br><span class="line"><span class="comment">%</span></span><br><span class="line"><span class="comment">%   BW = EDGE(I,'log',THRESH,SIGMA) 手动选取高斯滤波函数的sigma参数，默认为2</span></span><br><span class="line"><span class="comment">%</span></span><br><span class="line"><span class="comment">%   [BW,thresh] = EDGE(I,'log',...) 返回阈值</span></span><br><span class="line"></span><br><span class="line"><span class="comment">%   Canny Method</span></span><br><span class="line"><span class="comment">%   ----------------------------</span></span><br><span class="line"><span class="comment">%   BW = EDGE(I,'canny') 选用canny方法.（自动选取阈值）</span></span><br><span class="line"><span class="comment">%</span></span><br><span class="line"><span class="comment">%   BW = EDGE(I,'canny',THRESH) 手动输入阈值，形式为</span></span><br><span class="line"><span class="comment">%   [lowthr,highthr],即要输入大小两个阈值，前者小于后者，一般按照经验令 lowthr=0.5*highthr</span></span><br><span class="line"><span class="comment">%</span></span><br><span class="line"><span class="comment">%   BW = EDGE(I,'canny',THRESH,SIGMA)</span></span><br><span class="line"><span class="comment">%   由于canny算法也会用到高斯滤波，所以也可以手动设置sigma的值，默认为2</span></span><br><span class="line"><span class="comment">%</span></span><br><span class="line"><span class="comment">%   [BW,thresh] = EDGE(I,'canny',...) 返回阈值，注意有两个参数  thresh=[lowthr,highthr]</span></span><br></pre></td></tr></table></figure>



<p>运行结果显示：<br><img src="/blog_matlab/blog_matlab/2019/10/11/est-edge-example1-m/edge_example1.m.png" alt></p>
<p>z</p>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://lxydd.gitee.io/blog_matlab/2019/10/11/est-edge-example1-m/" data-id="ck8rgajbn0005jguv0ei21lhw" class="article-share-link">Share</a>
      
      
    </footer>
  </div>
  
    
<nav id="article-nav">
  
    <a href="/blog_matlab/2019/11/10/mgucv%E4%BC%A0Mat%E5%85%A5Matlab/" id="article-nav-newer" class="article-nav-link-wrap">
      <strong class="article-nav-caption">Newer</strong>
      <div class="article-nav-title">
        
          Emgucv传Mat入Matlab
        
      </div>
    </a>
  
  
    <a href="/blog_matlab/2019/10/11/atlab%E6%B5%8B%E8%AF%95%E6%96%87%E4%BB%B6%E8%B7%AF%E5%BE%84/" id="article-nav-older" class="article-nav-link-wrap">
      <strong class="article-nav-caption">Older</strong>
      <div class="article-nav-title">matlab测试文件路径</div>
    </a>
  
</nav>

  
</article>

</section>
        
          <aside id="sidebar">
  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Categories</h3>
    <div class="widget">
      <ul class="category-list"><li class="category-list-item"><a class="category-list-link" href="/blog_matlab/categories/SHH/">SHH</a></li><li class="category-list-item"><a class="category-list-link" href="/blog_matlab/categories/%E6%B5%8B%E8%AF%95%E4%BB%A3%E7%A0%81/">测试代码</a></li></ul>
    </div>
  </div>


  
    

  
    
  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Archives</h3>
    <div class="widget">
      <ul class="archive-list"><li class="archive-list-item"><a class="archive-list-link" href="/blog_matlab/archives/2020/04/">April 2020</a></li><li class="archive-list-item"><a class="archive-list-link" href="/blog_matlab/archives/2019/11/">November 2019</a></li><li class="archive-list-item"><a class="archive-list-link" href="/blog_matlab/archives/2019/10/">October 2019</a></li></ul>
    </div>
  </div>


  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Recent Posts</h3>
    <div class="widget">
      <ul>
        
          <li>
            <a href="/blog_matlab/2020/04/08/atlab%E6%8B%BC%E6%8E%A5-%E8%BE%93%E5%87%BA%E5%AD%97%E7%AC%A6%E4%B8%B2/">Matlab拼接&amp;输出字符串</a>
          </li>
        
          <li>
            <a href="/blog_matlab/2019/11/10/atlab%E9%BB%98%E8%AE%A4%E6%95%B0%E6%8D%AE%E7%B1%BB%E5%9E%8B/">Matlab默认数据类型</a>
          </li>
        
          <li>
            <a href="/blog_matlab/2019/11/10/mgucv%E4%BC%A0Mat%E5%85%A5Matlab/">Emgucv传Mat入Matlab</a>
          </li>
        
          <li>
            <a href="/blog_matlab/2019/10/11/est-edge-example1-m/">test_edge_example1.m</a>
          </li>
        
          <li>
            <a href="/blog_matlab/2019/10/11/atlab%E6%B5%8B%E8%AF%95%E6%96%87%E4%BB%B6%E8%B7%AF%E5%BE%84/">matlab测试文件路径</a>
          </li>
        
      </ul>
    </div>
  </div>

  
</aside>
        
      </div>
      <footer id="footer">
  
  <div class="outer">
    <div id="footer-info" class="inner">
      &copy; 2020 John Doe<br>
      Powered by <a href="http://hexo.io/" target="_blank">Hexo</a>
    </div>
  </div>
</footer>
    </div>
    <nav id="mobile-nav">
  
    <a href="/blog_matlab/" class="mobile-nav-link">Home</a>
  
    <a href="/blog_matlab/archives" class="mobile-nav-link">Archives</a>
  
</nav>
    

<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>


  
<link rel="stylesheet" href="/blog_matlab/fancybox/jquery.fancybox.css">

  
<script src="/blog_matlab/fancybox/jquery.fancybox.pack.js"></script>




<script src="/blog_matlab/js/script.js"></script>




  </div>
</body>
</html>